{% extends "zato/index.html" %}

{% block html_title %}Deliveries : {{ req.zato.args.state }}{% endblock %}

{% block "extra_css" %}
    <link rel="stylesheet" type="text/css" href="/static/css/jquery.alerts.css">
    <link rel="stylesheet" type="text/css" href="/static/css/slideout.css">
{% endblock %}

{% block "extra_js" %}

    {% comment %} jQuery {% endcomment %}
    <script nonce="{{ CSP_NONCE }}" type="text/javascript" src="/static/jquery/jquery.tablesorter.min.js"></script>
    <script nonce="{{ CSP_NONCE }}" type="text/javascript" src="/static/jquery/jquery.cookie.js"></script>
    <script nonce="{{ CSP_NONCE }}" type="text/javascript" src="/static/jquery/jquery.alerts.min.js"></script>
    <script nonce="{{ CSP_NONCE }}" type="text/javascript" src="/static/jquery/jquery.ui.slideraccess.js"></script>
    <script nonce="{{ CSP_NONCE }}" type="text/javascript" src="/static/jquery/jquery.ui.timepicker.addon.js"></script>

    <script nonce="{{ CSP_NONCE }}" type="text/javascript" src="/static/js/common.js"></script>
    <script nonce="{{ CSP_NONCE }}" type="text/javascript" src="/static/js/pattern/delivery/look-up-task.js"></script>
    <script nonce="{{ CSP_NONCE }}" type="text/javascript" src="/static/js/pattern/delivery/index.js"></script>

    <script nonce="{{ CSP_NONCE }}">

    $.fn.zato.data_table.get_columns = function() {
        return [
            '_numbering',
            '_selection',
            'task_id',
            'created',
            'last_used',
            '_source_target_count',
            'check_after',
            'retry_repeats',
            'retry_seconds',
            'resubmit_count',
            '_edit',
            '_delete',
            'id',
        ]
    }
    </script>

{% endblock %}

{% block "content" %}
<h2 class="zato"><a href="{% url "pattern-delivery" %}?cluster={{ cluster_id }}&amp;target_type={{ req.zato.args.target_type }}">Guaranteed delivery</a> : {{ req.zato.args.def_name }} : {{ req.zato.args.state }}</h2>

{% include "zato/user-message.html" %}

<div id="markup">

    {% include "zato/pattern/delivery/action-panel.html" %}


    <table id="data-table">
        <thead>
            <tr class='ignore'>
                <th>&nbsp;</th>
                <th>&nbsp;</th>
                <th><a href="#">Task</a></th>
                <th><a href="#">Created</a></th>
                <th><a href="#">In-doubt since</a></th>
                <th><a href="#">Source/target count</a></th>
                <th><a href="#">Check after</a></th>
                <th><a href="#">Retry repeats</a></th>
                <th><a href="#">Retry seconds</a></th>
                <th><a href="#">RS#</a></th>
                <th>&nbsp;</th>
        </thead>

        <tbody>
        {% if items %}
        {% for item in items %}
            <tr class="{% cycle 'odd' 'even' %}" id='tr_{{ item.task_id }}'>
                <td class='numbering'>&nbsp;</td>
                <td class="impexp"><input type="checkbox" /></td>
                <td><a href="{% url "pattern-delivery-details" item.task_id %}?cluster={{ cluster_id }}">{{ item.task_id }}</a></td>
                <td>{{ item.creation_time }}</td>
                <td>{% if req.zato.args.state == 'in-doubt' %}{{ item.last_used }}{% else %}<span class="form_hint">n/a</a>{% endif %}</td>
                <td>{{ item.source_count }}/{{ item.target_count }}</td>
                <td>{{ item.check_after }}</td>
                <td>{{ item.retry_repeats }}</td>
                <td>{{ item.retry_seconds }}</td>
                <td>{{ item.resubmit_count }}</td>
                <td><a href="javascript:$.fn.zato.pattern.delivery.in_doubt.resubmit('{{ item.task_id }}', '{{ cluster_id }}')">Resubmit</a></td>
                <td class='ignore item_id_{{ item.task_id }}'>{{ item.task_id }}</td>
            </tr>
        {% endfor %}
        {% else %}
            <tr class='ignore'>
                <td colspan='11'>No results</td>
            </tr>
        {% endif %}

        </tbody>
    </table>

    {% include "zato/pattern/delivery/look-up-task.html" %}

{% if total_results %}
    <br/>
    {% include "zato/pattern/delivery/action-panel.html" %}
    <br/>
{% endif %}

</div>

<form>
    <input type="hidden" id="js_date_format" value="{{ js_date_format }}" />
    <input type="hidden" id="js_time_format" value="{{ js_time_format }}" />
    <input type="hidden" id="js_ampm" value="{{ js_ampm }}" />
    <input type="hidden" id="cluster_id" value="{{ cluster_id }}" />
</form>




{% endblock %}
